package org.gruposp2p.proyectokarma.domain;

import org.hibernate.search.annotations.DocumentId;
import javax.persistence.GeneratedValue;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import static javax.persistence.GenerationType.IDENTITY;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.Resolution;

@Indexed
@Entity
@Table(name="Comment")
public class Comment implements java.io.Serializable {

	 private static final long serialVersionUID = 1L;
	 
	 @Id @GeneratedValue(strategy=IDENTITY)
     @Column(name="id", unique=true, nullable=false)
     @DocumentId
     private Long id;
     @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name="peerFromId", nullable=false)
     private Peer peerFrom;
     @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name="documentId")
     private Document document;
     @DateBridge( resolution = Resolution.DAY )
     @Temporal(TemporalType.TIMESTAMP)
     @Column(name="dateCreated", length=23)
     private Date dateCreated;
     @Column(name="content", nullable=false)
     @Field
     private String content;
   
     public Comment() { }
	
     public Comment(Long id, Peer peerFrom, Document document,
            String name, Date dateCreated, Date lastUpdated, String content) {
        this.id = id;
        this.peerFrom = peerFrom;
        this.document = document;
        this.dateCreated = dateCreated;
        this.content = content;
     }
   
     public Long getId() {
    	 return this.id;
     }
    
     public void setId(Long id) {
        this.id = id;
     }

     public Peer getPeerFrom() {
        return this.peerFrom;
     }
    
     public void setPeerFrom(Peer peerFrom) {
        this.peerFrom = peerFrom;
     }
     
     public Document getDocument() {
    	 return this.document;
     }
    
     public void setDocument(Document document) {
    	 this.document = document;
     }

    public Date getDateCreated() {
        return this.dateCreated;
    }
    
    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }
    
    public String getContent() {
        return this.content;
    }
    
    public void setContent(String content) {
        this.content = content;
    }

}


